Add an `rpath` option to the profile section
authorAlex Crichton <alex@alexcrichton.com>
Wed, 15 Oct 2014 17:28:15 +0000 (10:28 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 15 Oct 2014 17:28:38 +0000 (10:28 -0700)
This will enable passing `-C rpath` on all compiles to rustc itself.

Closes #705

src/cargo/core/manifest.rs
src/cargo/ops/cargo_rustc/mod.rs
src/cargo/util/toml.rs
tests/test_cargo_profiles.rs

index fced063ef156c0c03a7fc36789a685b2251b6fe3..ac3629eb49a619ccb8e83a372565e7e6393bf69e 100644 (file)
@@ -111,6 +111,7 @@ pub struct Profile {
     opt_level: uint,
     codegen_units: Option<uint>,    // None = use rustc default
     debug: bool,
+    rpath: bool,
     test: bool,
     doctest: bool,
     doc: bool,
@@ -126,6 +127,7 @@ impl Profile {
             opt_level: 0,
             codegen_units: None,
             debug: false,
+            rpath: false,
             test: false,
             doc: false,
             dest: None,
@@ -218,6 +220,10 @@ impl Profile {
         self.debug
     }
 
+    pub fn get_rpath(&self) -> bool {
+        self.rpath
+    }
+
     pub fn get_env(&self) -> &str {
         self.env.as_slice()
     }
@@ -241,6 +247,11 @@ impl Profile {
         self
     }
 
+    pub fn rpath(mut self, rpath: bool) -> Profile {
+        self.rpath = rpath;
+        self
+    }
+
     pub fn test(mut self, test: bool) -> Profile {
         self.test = test;
         self
@@ -275,6 +286,7 @@ impl<H: hash::Writer> hash::Hash<H> for Profile {
             opt_level,
             codegen_units,
             debug,
+            rpath,
             plugin,
             dest: ref dest,
             harness: harness,
@@ -287,7 +299,7 @@ impl<H: hash::Writer> hash::Hash<H> for Profile {
             test: _,
             doctest: _,
         } = *self;
-        (opt_level, codegen_units, debug, plugin, dest, harness).hash(into)
+        (opt_level, codegen_units, debug, rpath, plugin, dest, harness).hash(into)
     }
 }
 
index fd83b7dbba674ac8e2e886c6a834819c26b9e805..c035441950d60516517203115247209263e1d247 100644 (file)
@@ -366,7 +366,8 @@ fn build_base_args(cx: &Context,
         let root_profile = target.get_profile();
         if root_profile.get_env() != profile.get_env() { continue }
         profile = profile.opt_level(root_profile.get_opt_level())
-                         .debug(root_profile.get_debug());
+                         .debug(root_profile.get_debug())
+                         .rpath(root_profile.get_rpath())
     }
 
     if profile.get_opt_level() != 0 {
@@ -405,6 +406,10 @@ fn build_base_args(cx: &Context,
         None => {}
     }
 
+    if profile.get_rpath() {
+        cmd = cmd.arg("-C").arg("rpath");
+    }
+
     return cmd;
 }
 
index 37430b2a1095a451bc54f5058b244c2ec7df907f..8fe9829bf0e8635e1c9db4123ee870080799d9ea 100644 (file)
@@ -227,6 +227,7 @@ pub struct TomlProfile {
     opt_level: Option<uint>,
     codegen_units: Option<uint>,
     debug: Option<bool>,
+    rpath: Option<bool>,
 }
 
 #[deriving(Decodable)]
@@ -613,7 +614,9 @@ fn normalize(libs: &[TomlLibTarget],
         let opt_level = toml.opt_level.unwrap_or(profile.get_opt_level());
         let codegen_units = toml.codegen_units;
         let debug = toml.debug.unwrap_or(profile.get_debug());
+        let rpath = toml.rpath.unwrap_or(profile.get_rpath());
         profile.opt_level(opt_level).codegen_units(codegen_units).debug(debug)
+               .rpath(rpath)
     }
 
     fn target_profiles(target: &TomlTarget, profiles: &TomlProfiles,
index c85b43db064d4425c289050c69ed719eb1527567..f7e5024cb850b9d2fef2a39e95bda318e9799809 100644 (file)
@@ -21,6 +21,7 @@ test!(profile_overrides {
             [profile.dev]
             opt-level = 1
             debug = false
+            rpath = true
         "#)
         .file("src/lib.rs", "");
     assert_that(p.cargo_process("build").arg("-v"),
@@ -31,6 +32,7 @@ test!(profile_overrides {
         --cfg ndebug \
         -C metadata=[..] \
         -C extra-filename=-[..] \
+        -C rpath \
         --out-dir {dir}{sep}target \
         --dep-info [..] \
         -L {dir}{sep}target \